
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<title>Xpaas </title>
		<script src="./js/jquery.min.js"></script>
		<script type="text/javascript" src="./js/jquery.jstree.min.pack.js"></script>
		<link rel="Shortcut Icon" href="favicon.ico">

		<link rel="stylesheet" href="./js/codemirror/codemirror.css">
		<script src="./js/codemirror/codemirror-compressed.js"></script>
		<script src="./js/codemirror/clike2-compressed.js"></script>
		<link rel="stylesheet" href="./js/codemirror/default.css">

		<style>
body,html {
	height: 100%;
	margin: 0 auto;
}

#div_pannel {
	height: 400px;
}

#div_tab {
	background: #ddd;
	height: 17px;
	border-bottom: 1px solid #FAFAFA;
}

#div_tab li {
	float: left;
	text-align: center;
	position: relative;
	list-style: none;
}

#div_tab li {
	background: #DDD;
	border-right: 1px solid #ccc;
	border-bottom: 1px solid #EEE;
	height: 17px;
}

#div_tab li span {
	height: 17px;
	line-height: 17px;
}

#div_tab li.crent {
	background: #FAFAFA;
	border-left: 1px solid #DDD;
	margin-top: 0px;
	height: 17px;
}

#div_tab li.crent span {
	height: 17px;
	line-height: 17px;
}

#div_tab li,#div_tab li.crent {
	color: #fff;
	background-repeat: no-repeat;
	background-position: 0 0;
}

#div_tab li span,#div_tab li.crent span {
	display: inline-block;
	padding: 0 30px 0 10px;
	background-repeat: no-repeat;
	background-position: right bottom;
}

#div_tab li span:hover {
	background: #EEE;
	height: 17px;
	line-height: 17px;
}

#div_tab li .menua {
	color: #000;
	font-size: 12px;
	text-decoration: none;
	position: relative;
}

#div_tab li.crent .menua,#div_tab li .menua:hover {
	color: #ff0000;
}

#div_tab li .win_close,#div_tab li.crent .win_close {
	width: 14px;
	height: 14px;
	position: absolute;
	top: 2px;
	right: 5px;
	cursor: pointer;
	display: block;
	overflow: hidden;
	background: url(./close.gif)
		no-repeat;
}

#div_tab li .win_close {
	background-position: 0 -14px;
	opacity: 0.2;
}

#div_tab li .win_close:hover {
	background-position: 0 0;
	opacity: 1;
}

.clearfix:after {
	content: ".";
	display: block;
	height: 0;
	clear: both;
	visibility: hidden;
}

* html .clearfix {
	height: 1%;
}

*+html .clearfix {
	height: 1%;
}

.clearfix {
	display: inline-block;
}

/* Hide from IE Mac */
.clearfix {
	display: block;
}

#div_box {
	border: 1px #ccc solid;
}

.CodeMirror {
	width: 791px;
	overflow: auto;
	border-left: 1px solid #EAEAEA;
	float: left;
}

.CodeMirror pre {
	color: #AAA;
}

.CodeMirror-scroll {
	overflow: auto;
	height: 393px;
	position: relative;
}

.CodeMirror-gutter {
	background-color: #FFF;
	border-right: 1px solid #FFF;
	min-width: 2.3em;
}

.CodeMirror-gutter-text {
	color: #AAA;
	border-right: 1px solid #FFF;
	padding: .3em .2em .4em .4em;
}
</style>
		<link rel="stylesheet" type="text/css" href="./css/css.css">
		<style type="text/css">
html,body,div,span,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,acronym,address,code,del,dfn,em,img,q,dl,dt,dd,ol,ul,li,fieldset,form,label,legend,table,caption,tbody,tfoot,thead,tr,th,td
	{
	margin: 0;
	padding: 0;
	border: 0;
	font-style: inherit;
	font-size: 100%;
	font-family: inherit;
	color: #004276;
}

body {
	font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
	font-size: 14px;
	margin: 0;
	font-weight: inherit;
	font-style: inherit;
	color: #004276;
}

table {
	border-collapse: collapse;
	border: solid #ccc;
}

#mainContent {
	margin-top: 0px;
	padding: 2px 1px 2px 2px;
	border: 0;
}

a {
	color: #369;
	cursor: pointer;
}

.jstree a {
	color: #369;
	cursor: pointer;
	font-weight: bold;
}

#vakata-contextmenu.jstree-default-context a {
	color: black;
	font-weight: normal;
}

#topbar a {
	text-decoration: none; /*color: #eee;*/
}
</style>
		<script language="Javascript" type="text/javascript">

function Run(){
	
 var classPath='C:/YoujavaitBin/Youjavait/src';
 var mainSource='';
 var mainClass='';

 var Compiler=document.Compiler;

 for(var i=0;i<aryff.length;++i){
   if(aryff[i].id.lastIndexOf('-')==aryff[i].id.length-1){
		   var arr2=aryff[i].id.split('-');
		   var pathstr='';
		   for(var j=0;j<arr2.length-1;j++){
		    if(j==0){

			  pathstr=arr2[j];
			  Compiler.newFolder('C:/YoujavaitBin/'+pathstr.replace("Youjavait","Youjavait"));
			 }else{
			
			  pathstr=pathstr+'/'+arr2[j];
			  Compiler.newFolder('C:/YoujavaitBin/'+pathstr.replace("Youjavait","Youjavait"));
			 }
		   }
          
	}else{
          var arr2=aryff[i].id.split('-');
		  var pathstr='';
		   for(var j=0;j<arr2.length;j++){
             if(j==0){
			   
			   pathstr=arr2[j];
			   
			   Compiler.newFolder('C:/YoujavaitBin/'+pathstr.replace("Youjavait","Youjavait"));
			  
				
			 }else if(j==arr2.length-1){
				var temp=aryff[i].id.replace('9578','.');

				if(aryff[i].text.match(/public\s*static\s*void\s*main/g)){
		         mainSource='C:/YoujavaitBin/'+temp.replace(/-/g,'/').replace("Youjavait","Youjavait");
				 mainClass=aryff[i].title.replace('.java','');
                 //alert('-'+mainSource+'-'+mainClass+'-');
				}
				
                Compiler.writeFile(aryff[i].text,'C:/YoujavaitBin/'+temp.replace(/-/g,'/').replace("Youjavait","Youjavait") );
			   
			 }else{
               
			   pathstr=pathstr+'/'+arr2[j];
			   Compiler.newFolder('C:/YoujavaitBin/'+pathstr.replace("Youjavait","Youjavait"));
			  
			 }
		   }
		   
    }
  
 }

var outStr=Compiler.compiler(classPath,mainSource,mainClass);
document.getElementById("Com_applet").style.display="none";
document.getElementById('resultmainbax').innerHTML="<pre style='font-family:Arial;font-size:14px;margin:1px 5px;'>"+outStr+"</pre>";
editor.focus();

}

function Save(){

 var codedata='';

 for(var i=0;i<aryff.length;++i)
  codedata='@x4x@id'+aryff[aryff.length-1-i].id+'@x4x@title'+aryff[aryff.length-1-i].title+'@x4x@text'+aryff[aryff.length-1-i].text+'end@x2x@end'+codedata;
 
 document.codeform.codedata.value=codedata;

 document.codeform.action="Youjavait";
 document.codeform.submit();
}

function Fork(){

 var codedata='';
 for(var i=0;i<aryff.length;++i){
  codedata='@x4x@id'+aryff[aryff.length-1-i].id+'@x4x@title'+aryff[aryff.length-1-i].title+'@x4x@text'+aryff[aryff.length-1-i].text+'end@x2x@end'+codedata;
 }

 document.codeform.codedata.value=codedata;
 document.codeform.action="Youjavait";
 document.codeform.submit();
}


function savebtn(){
 var codedata='';
 var pid='Youjavait';

 for(var i=0;i<aryff.length;++i){
  codedata='@x4x@id'+aryff[aryff.length-1-i].id+'@x4x@title'+aryff[aryff.length-1-i].title+'@x4x@text'+aryff[aryff.length-1-i].text+'end@x2x@end'+codedata;
 }

 $.post("./index.php", { "codedata":codedata,"pid":pid },function(data){/*alert(data);*/} );
}

function selectCopy(){
 if(document.getElementById("copylink")!=null)
 document.getElementById("copylink").onclick();

}
</script>

		<link rel="stylesheet" type="text/css"
			href="./js/thickbox/thickbox.css">

		<script type="text/javascript"
			src="./js/thickbox/thickbox-compressed.js"></script>
		<link rel="stylesheet" href="./openid-selector/css/openid.css" />
		<script type="text/javascript"
			src="./openid-selector/js/openid-jquery-compressed.js"></script>
		<script type="text/javascript">
	$(document).ready(function() {openid.init('openid_identifier');});
</script>
		<script>
	function checkusername()
{
    var regex=/^[0-9A-Za-z_]{6,15}$/
    var s=document.getElementById("username").value;
	if(!regex.exec(s)){
	document.getElementById("msg_username").innerHTML="A username is required.";	
    document.getElementById("msg_username").style.display="inline";
	}else{
    document.getElementById("msg_username").style.display="inline";
	document.getElementById("msg_username").style.color="green";
	document.getElementById("msg_username").innerHTML="User name available";
	
	}
}
</script>
	</head>

	<body class='preview' onload="selectCopy()">
		<div id='header'
			style='background: #3D668F url(./img/top-bg.png) repeat-x; height: 35px;'>
			<div style="width: 994px; margin: 0 auto;">
				<div id='logo'>
					<a href="http://www.siat.ac.cn">xPaas</a>
				</div>
				<div id='topbar'>
					<a class="button light group light  left" href=".">Create a new
						project</a>&nbsp;
					<a class="button light group light  left thickbox"
						href="http://www.siat.ac.cn/users/myproject.php?uid=2088?keepThis=true&TB_iframe=true&height=547&width=780"
						title="My projects" style="padding: 6px 1px 6px 10px;">user2088</a>
					<div class="button group  right tall"
						style="width: 82px; border-left: 1px solid #FAFAFA;">
						<a class="save title"
							style="background: url(./img/down.png) no-repeat 51px center; padding: 3px 2px; padding-right: 38px;"><img
								style="-webkit-border-radius: 2px; -moz-border-radius: 2px; border-radius: 2px; margin-top: -2px;"
								src="http://www.gravatar.com/avatar/6d9d03384ddbe8cba68d435e07775cae?s=22&d=mm&r=G"
								alt="" width="22px" height="22px" />
						</a>&nbsp;
						<a class="button light save group" href="./users/logout.php"
							style="padding-left: 10px; width: 50px;">Log out</a><a
							class="button light save group thickbox"
							href="http://www.siat.ac.cn/users/myproject.php?uid=2088?keepThis=true&TB_iframe=true&height=547&width=780"
							title="My  project" style="padding-left: 10px; width: 50px;">Projects</a>
					</div>
				</div>
			</div>
		</div>
		<div style='width: 990px; margin: 0 auto;'>
			<div id="control" style='width: 990px; height: 3px; background: #ccc'>

				<div class="control">
					<div class="buttons">
						<div class="button group gap right tall">
							<a style="padding-right: 43px;" class="save title">File</a>
							<a style="padding-left: 21px;" title="Create a new class"
								class="button light save group"
								onclick='javascript:$("#demo").jstree("create", null, "last", { "attr" : { "rel" : "default" } });'>New
								Class</a>
							<a style="padding-left: 21px;" title="Create a new folder"
								class="button clone group light"
								onclick='javascript:$("#demo").jstree("create", null, "last", { "attr" : { "rel" : "folder" } });'>New
								Folder</a>
							<a style="padding-left: 21px;" title="" class="button group"
								onclick='$("#demo").jstree("rename")'>Rename</a>
							<a style="padding-left: 21px;" title=""
								class="button  group light"
								onclick='$("#demo").jstree("remove")'>Delete</a>
						</div>

						<a class="tab button source group left" accesskey="1"
							onclick='document.getElementById("Com_applet").style.display="block";document.getElementById("resultmainbax").innerHTML="<pre style=\"color:#222;font-family:Arial;font-size:16px;margin: 0px 5px;\"><img src=\"./img/ajax-loader-bar-small.gif\"></pre>";setTimeout(Run,10);'
							style='padding: 6px 12px 6px 12px;'>Debug</a>
						<a class="tab button preview group right gap" accesskey="2"
							onclick='document.getElementById("Com_applet").style.display="block";document.getElementById("resultmainbax").innerHTML="<pre style=\"color:#222;font-family:Arial;font-size:16px;margin: 0px 5px;\"><img src=\"./img/ajax-loader-bar-small.gif\"></pre>";setTimeout(Run,10);'
							style='padding: 6px 20px;'>Run </a>

						<form name='codeform' method='post'>
							<input type='hidden' name='codedata' value=''>
							<input type='hidden' name='pid' value='Youjavait'>
						</form>

					</div>
				</div>

				<div class="help" style="padding-right: 2px;">

					<a id="save" title=""
						class=" left button light save group right left"
						href="javascript:Save();">Save</a>

				</div>

			</div>
			<div id="bin" style='top: 70px;'>
				<div id='mainContent' style='width: 990px; background: #fff;'>
					<table style='width: 980px; background: #fff; border: 0;'>

						<tr>
							<td valign='top'
								style='width: 191px; border-top: 1px solid #E9EAEA; border-left: 1px solid #ccc'>
								<div id="demo"
									style='font-family: Verdana; width: 191px; height: 413px; overflow: auto; font-size: 12px;'></div>
							</td>
							<td
								style='border-top: 1px solid #E9EAEA; border-right: 1px solid #ccc; background: #FFF; width: 785px;'>
								<ul class="clearfix" id="div_tab"></ul>
								<div id="div_pannel"></div>
							</td>
						</tr>
						<tr>
							<td colspan=2
								style='border-width: 0 1px 1px 1px; border-style: solid; border-color: #ccc;'>
								<div id='resultbox'
									style='margin-top: -5px; height: 143px; border: solid #EAEAEA; border-width: 1px 0 0 0;'>
									<div id='resultheadbax'
										style='width: 100%; color: #3E3E3E; font-size: 13px; font-weight: bold; height: 13px; border-width: 1px 0px; border-color: #fff; border-style: solid; background: #EEE;'>
										&nbsp;Output:
										<div id='Com_applet'
											style='text-align: center; display: block;'>
											<!--<applet code='com.sun.tools.javac.Compiler.class'
												name="Compiler" archive="Compiler.jar" width="200"
												height="121">
											Sorry, your browser doesn't support Java(tm)
											</applet>
											  -->
										</div>

									</div>
									<div id='resultmainbax'
										style='width: 984px; height: 127px; overflow: auto;'></div>

								</div>

							</td>
						</tr>

					</table>
					<div id="myOnPageContent"
						style='display: none; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;'>
						<p></p>
						<br />

						<form action="./lightopenid/auth.php" method="get"
							id="openid_form">
							<input type="hidden" name="action" value="verify" />
							<fieldset>
								<legend>
									<h1 style='font-size: 170%;'>
										Login or Create New Account
									</h1>
								</legend>

								<div id="openid_choice" style="padding-top: 16px;">
									<div id="openid_btns"></div>
								</div>
								<div id="openid_input_area" style="padding-left: 2px;">
									<input id="openid_identifier" name="openid_identifier"
										type="text" value="http://" />
									<input id="openid_submit" type="submit" value="Sign-In" />
								</div>

							</fieldset>
						</form>
					</div>
				</div>

			</div>

		</div>

	</body>
</html>
<script type="text/javascript">
$(function () {
  $("#demo").jstree({ 
		"xml_data" : {
		   "data":""+ 
     "<root  state='open'>"+
"<item id='Youjavait-'  rel='drive' state='open'>"+
"<content><name>Youjavait</name></content>"+
"</item>"+
"<item id='Youjavait-src-' parent_id='Youjavait-' rel='folder' state='open'>"+
"<content><name>src</name></content>"+
"</item>"+
"<item id='Youjavait-src-Test9578java' parent_id='Youjavait-src-' rel='default' >"+
"<content><name>Test.java</name></content>"+
"</item>"+
"</root>"		 },
		 "plugins" : [ "themes", "xml_data", "ui", "crrm",  "dnd",  "types",  "contextmenu" ],
	     "themes" : {"theme" : "default","dots" : false,"icons" : true},
		 "types" : {
				// I set both options to -2, as I do not need depth and children count checking
				// Those two checks may slow jstree a lot, so use only when needed
				"max_depth" : -2,
				"max_children" : -2,
				// I want only `drive` nodes to be root nodes 
				// This will prevent moving or creating any other type as a root node
				"valid_children" : [ "drive" ],
				"types" : {
					"default" : {
						// I want this type to have no children (so only leaf nodes)
						// In my case - those are files
						"valid_children" : "none",
						// If we specify an icon for the default type it WILL OVERRIDE the theme icons
						"icon" : {
							"image" : "./img/jfile.png"
						},
						"start_drag" : false,
                        "move_node" : false
					},
					"folder" : {
						// can have files and other folders inside of it, but NOT `drive` nodes
						"valid_children" : [ "default", "folder" ],
						"icon" : {
							"image" : "./img/folder.png"
						},
                        "start_drag" : false,
						"move_node" : false
					},
					"drive" : {
						// can have files and folders inside, but NOT other `drive` nodes
						"valid_children" : [ "default", "folder" ],
						"icon" : {
							"image" : "./img/jproject.gif"
						},
						"start_drag" : false,
						"move_node" : false,
						"delete_node" : false,
						"remove" : false
					}
				},

			},

"contextmenu" : {

   items: {
          "ccp" : false,
	      "create" : false,
	      "remove" : false,
	      "rename" : false,
          "newclass" : {
            "label" : "New Class",
            "action"            : function (obj) { this.create(obj); },
            "_disabled"         : false
          },
          "newpackage" : {
            "label" : "New Folder",
            "action"            : function (obj) { $("#demo").jstree("create", obj, "last", { "attr" : { "rel" : "folder" } }); },
            "_disabled"         : false
          },
	      "rename2" : {
             "label" : "Rename",
             "action"            : function (obj) { this.rename(obj); },
             "_disabled"         : false
          },
          "delete2" : {
             "label" : "Delete",
             "action"            : function (obj) { this.remove(obj); },
             "_disabled"         : false
          },
        }

}
		})
.bind("select_node.jstree", function (event, data) {

		   selectFile(data.rslt.obj.attr("id"));

  })

.bind("create.jstree", function (e, data) {

	if(data.rslt.obj.attr("rel")=='default'){
        
	  if(!addFile( data.rslt.parent.attr("id")+data.rslt.name.replace('.','9578') , data.rslt.name))
	    $.jstree.rollback(data.rlbk);	
      else
	    $(data.rslt.obj).attr("id", data.rslt.parent.attr("id")+data.rslt.name.replace('.','9578'));
	 
	      
	}else if(data.rslt.obj.attr("rel")=='folder'){
     
	  if(!addFolder(data.rslt.parent.attr("id")+data.rslt.name+'-' , data.rslt.name))
		$.jstree.rollback(data.rlbk);	
	  else
	    $(data.rslt.obj).attr("id", data.rslt.parent.attr("id")+data.rslt.name+'-');
	  		
	}
})
.bind("remove.jstree", function (e, data) {
			//data.rslt.obj.each(function () {
			//alert(data.rslt.obj.attr("id"));   
	        deleteFile(data.rslt.obj.attr("id"),data.rslt.obj.attr("rel"));		
		//});
	})
.bind("rename.jstree", function (e, data) {
	 var oldname='';
	 var parentid='';
	 //alert(data.rslt.new_name);

    if(data.rslt.obj.attr("rel")=='default'){
       for(var i=0;i<aryff.length;++i){
        if(aryff[i].id==data.rslt.obj.attr("id")){
         oldname=aryff[i].title;
		}
	   }
	  parentid=data.rslt.obj.attr("id").substr(0,data.rslt.obj.attr("id").lastIndexOf('-')+1);
	  //alert(oldname);

	  if(oldname==data.rslt.new_name||!rename(data.rslt.obj.attr("id"), parentid+data.rslt.new_name.replace('.','9578'), data.rslt.new_name)){
         $.jstree.rollback(data.rlbk);
      }else{
	 
	     $(data.rslt.obj).attr("id", parentid+(data.rslt.new_name).replace('.','9578'));
	  }      
	}else if(data.rslt.obj.attr("rel")=='folder'){
	  var str=data.rslt.obj.attr("id").substr(0,data.rslt.obj.attr("id").length-1);
	  oldname=str.substr(str.lastIndexOf('-')+1,str.length-1);

      parentid=str.substr(0,str.lastIndexOf('-')+1);

	  if(oldname==data.rslt.new_name||!rename(data.rslt.obj.attr("id"), parentid+data.rslt.new_name+'-', data.rslt.new_name)){
	     $.jstree.rollback(data.rlbk);	
	 
	  }else{
	     $(data.rslt.obj).attr("id", parentid+data.rslt.new_name+'-');
	  }		
	}
   })

});

  var crent='';
  var aryff=new Array();
  var box = document.createElement("textarea");
  box.id = "div_codebox";
  box.style.height = "400px";
  box.style.width = "780px";
  document.getElementById("div_pannel").appendChild(box);


  var editor = CodeMirror.fromTextArea(document.getElementById("div_codebox"), {
  lineNumbers: true,
  matchBrackets: true,
  mode: "text/x-java",
  onChange: function() {
       for(var i=0;i<aryff.length;++i){
            if(aryff[i].id==crent){
              aryff[i].text=editor.getValue();
              break;
            }
          }
		 // editor.focus();
       },
 onKeyEvent: function(i, e) {

          if (e.ctrlKey&&(e.keyCode == 68||e.keyCode == 82)) {
             e.stop();
			//editor.focus();
			document.getElementById("Com_applet").style.display="block";
            document.getElementById("resultmainbax").innerHTML="<pre style=\"color:#222;font-family:Arial;font-size:16px;margin: 0px 5px;\"><img src=\"./img/ajax-loader-bar-small.gif\"></pre>";setTimeout(Run,20);
			editor.focus();
			
			
          }
        }
  });

   function CreateTab(id,title){

			var tablist = document.getElementById("div_tab").getElementsByTagName('li');
				
			if (tablist.length > 0)
			{
				for (i = 0; i < tablist.length; i++)
				{
					tablist[i].className = "";
						
				}
			}

			var tab = document.createElement("li");
			tab.className = "crent";
			tab.id = 'tab_'+id;
			var litxt = "<a href=\"javascript:;\" onclick=\"javascript:selectTab('" + id + "')\" title=" + title + " class=\"menua\"><span>" +title + "</span></a><a onclick=\"ClosedTab('" + id + "')\" class=\"win_close\" title=\"close\"><a>";
			tab.innerHTML = litxt;
			document.getElementById("div_tab").appendChild(tab);
			crent=id;
			


  }
 new_file={id:"Youjavait-",text:"--isFolder--",title:"Youjavait"};
aryff.push(new_file);
new_file={id:"Youjavait-src-",text:"--isFolder--",title:"src"};
aryff.push(new_file);
new_file={id:"Youjavait-src-Test9578java",text:"public class Test{ \n\n\n     public static void main(String[] args){ \n	\n      System.out.println(\"hello world!\");\n\n     }\n  \n}",title:"Test.java"};
aryff.push(new_file);
CreateTab("Youjavait-src-Test9578java","Test.java");editor.setValue("public class Test{ \n\n\n     public static void main(String[] args){ \n	\n      System.out.println(\"hello world!\");\n\n     }\n  \n}");editor.focus();

function selectTab(id){

	var tablist = document.getElementById("div_tab").getElementsByTagName('li');
	var pannellist = document.getElementById("div_pannel").getElementsByTagName('pre');

	for (i = 0; i < tablist.length; i++)
	{ 
		tablist[i].className = "";
					
	}
	document.getElementById('tab_'+id).style.display = 'block';
	document.getElementById('tab_'+id).className = 'crent';

    crent=id;


   for(var i=0;i<aryff.length;++i){
    if(aryff[i].id==id&&(aryff[i].text!='--isFolder--')){
    
       editor.setValue(aryff[i].text);
     }

   }
 }

function selectFile(id){

  if(id!=crent){
    for(var i=0;i<aryff.length;++i){
      if(aryff[i].id==id&&(aryff[i].text!='--isFolder--')){
	   var tablist = document.getElementById("div_tab").getElementsByTagName('li');
	   

	    for (j = 0; j < tablist.length; j++)
	    { 
		tablist[j].className = "";                                                                                                     
					
	    }
	   if (document.getElementById("tab_"+id) == null){

         CreateTab(id,aryff[i].title);
		 //alert(id+'  '+aryff[i].text+' '+crent);
		 crent=id;
		 editor.setValue(aryff[i].text);

		}else{
		crent=id;
		document.getElementById("tab_"+id).className="crent"; 
		editor.setValue(aryff[i].text);
		
		}
        
      }
    }
  }
 }


 Array.prototype.remove=function(dx){
  if(isNaN(dx)||dx>this.length){return false;}
   for(var i=0,n=0;i<this.length;i++)
   {
     if(this[i]!=this[dx])
    {
      this[n++]=this[i];
     }
   }
    this.length-=1
  }

 function deleteFile(id,rel){

 for(var i=0;i<aryff.length;i++){
   if(aryff[i].id==id){

     if(rel=='default'){
      	ClosedTab(id);
        aryff.remove(i);break;
     }else{
      
      for(var j=0;j<aryff.length;j++){
		  if(aryff[j].id.indexOf(id)!=-1){//alert('del 2'+id+'    '+aryff[j].id);

            //editAreaLoader.closeFile('example_1',aryff[j].id);

		    ClosedTab(id);

            aryff.remove(j);

		    j=0;
		  }
	   }
	   break;
     }
	
    }
   }

  }

  function addFile(id,title){

    var booltemp=true;
    for(var i=0;i<aryff.length;i++){
      if(aryff[i].id==id){
       booltemp=false;alert(id+' File already exists!');
       break;
      }
    }
    if(booltemp){

      if(id.indexOf(' ')==-1){

        if (document.getElementById("tab_"+id) == null)//��һ�δ򿪴��ļ� ����һ��tab
	    {
	  
           var new_file={id:"",text:"",title:""};
		   new_file.id=id;
		   new_file.text="class   "+title.replace('.java','')+"{\n\n\n\n\n}";
		   new_file.title=title;
      
           aryff.push(new_file);
           CreateTab(id,title);
           editor.setValue(new_file.text);

	     }


      }else{
        booltemp=false;
        alert("'"+title+"' "+'FileName can not have spaces');
      }

    }
   return booltemp;
  
  }


  function addFolder(id,title){
    var booltemp=true;
    for(var i=0;i<aryff.length;++i){
       if(aryff[i].id==id){
         booltemp=false;alert(title+' File already exists!');
         break;
       }
    }
    if(booltemp){

     if(title.indexOf(' ')==-1){
       var new_file={id:'',text:'',syntax:'java',title:''};
       new_file.id=id;
       new_file.title=title;
       new_file.text='--isFolder--';
       aryff.push(new_file);
 
      }else{
        alert("'"+title+"' "+'FileName can not have spaces');
      }

    }
    return booltemp;
  }

  function rename(id,new_id,new_title){

    var booltemp=false;
    if(new_title.indexOf(' ')!=-1){

       alert("'"+new_title+"' "+'FileName can not have spaces');
    }else{

     for(var i=0;i<aryff.length;++i){
      if(aryff[i].id==new_id){
         booltemp=true;
	     alert(new_title+' File already exists!');
         break;
      }else{
         if(aryff[i].id==id){
	
          if(id.length-1!=id.lastIndexOf('-')){
	       ClosedTab(id);
		   CreateTab(new_id,new_title);
	       
          // editAreaLoader.closeFile('example_1',aryff[i].id);
	       aryff[i].id=new_id;
	       aryff[i].title=new_title;
	  
           editor.setValue(aryff[i].text);
	       break;
		  }
		  booltemp=true;
	     }
    
      }
     }
    }

    return booltemp;
  }

 function ClosedTab(id)
 {          
	    
			var ob = document.getElementById('tab_'+id);
			ob.parentNode.removeChild(ob);

			var tablist = document.getElementById("div_tab").getElementsByTagName('li');
			var pannellist = document.getElementById("div_pannel").getElementsByTagName('pre');

			//document.getElementById('tab_'+id).style.display = 'none';

			//document.getElementById("div_"+tabid).style.display = "none";
			if(id==crent){
			  if (tablist.length >0)
			  {
				 tablist[tablist.length - 1].className = 'crent';

				

				 for(var i=0;i<aryff.length;++i){
                   if(aryff[i].id==(tablist[tablist.length - 1].id).replace("tab_","")&&(aryff[i].text!='--isFolder--')){
				      crent=aryff[i].id;
	
				      editor.setValue(aryff[i].text);
				   }
				 }
			
			   }	
			
			}else{

			  if (tablist.length >0)
			  {
				 tablist[tablist.length - 1].className = 'crent';
				
				 for(var i=0;i<aryff.length;++i){
                   if(aryff[i].id==crent&&(aryff[i].text!='--isFolder--')){
				     editor.setValue(aryff[i].text);
				   }
				 }
			
			   }	
			
			}	
 }
</script>